/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "ALBUM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Album.findAll", query = "SELECT a FROM Album a"),
    @NamedQuery(name = "Album.findByAlbumId", query = "SELECT a FROM Album a WHERE a.albumId = :albumId"),
    @NamedQuery(name = "Album.findByAlbumTitle", query = "SELECT a FROM Album a WHERE a.albumTitle = :albumTitle"),
    @NamedQuery(name = "Album.findByDiskNumber", query = "SELECT a FROM Album a WHERE a.diskNumber = :diskNumber"),
    @NamedQuery(name = "Album.findByReleaseDate", query = "SELECT a FROM Album a WHERE a.releaseDate = :releaseDate"),
    @NamedQuery(name = "Album.findByCreatedBy", query = "SELECT a FROM Album a WHERE a.createdBy = :createdBy"),
    @NamedQuery(name = "Album.findByCreatedDate", query = "SELECT a FROM Album a WHERE a.createdDate = :createdDate"),
    @NamedQuery(name = "Album.findByModifiedBy", query = "SELECT a FROM Album a WHERE a.modifiedBy = :modifiedBy"),
    @NamedQuery(name = "Album.findByModifiedDate", query = "SELECT a FROM Album a WHERE a.modifiedDate = :modifiedDate"),
    @NamedQuery(name = "Album.findByArtistNotNull", query = "SELECT a FROM Album a WHERE a.artistId is not null"),
    @NamedQuery(name = "Album.findByMusicGroupNotNull", query = "SELECT a FROM Album a WHERE a.musicGroupId is not null")   })
    
public class Album implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ALBUM_ID")
    private Long albumId;
    @Basic(optional = false)
    @Column(name = "ALBUM_TITLE")
    private String albumTitle;
    @Column(name = "DISK_NUMBER")
    private Integer diskNumber;
    @Basic(optional = false)
    @Column(name = "RELEASE_DATE")
    @Temporal(TemporalType.DATE)
    private Date releaseDate;
    @Basic(optional = false)
    @Column(name = "CREATED_BY")
    private String createdBy;
    @Basic(optional = false)
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
    @Column(name = "MODIFIED_BY")
    private String modifiedBy;
    @Column(name = "MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifiedDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "albumId")
    private List<Song> songList;
    @JoinColumn(name = "COMPANY_ID", referencedColumnName = "COMPANY_ID")
    @ManyToOne(optional = false)
    private Musicproductioncompany companyId;
    @JoinColumn(name = "MUSIC_GROUP_ID", referencedColumnName = "MUSIC_GROUP_ID")
    @ManyToOne
    private Musicgroup musicGroupId;
    @JoinColumn(name = "ARTIST_ID", referencedColumnName = "ARTIST_ID")
    @ManyToOne
    private Artist artistId;
    @JoinColumn(name = "TYPE_ID", referencedColumnName = "TYPE_ID")
    @ManyToOne(optional = false)
    private Albumtype typeId;

    public Album() {
    }

    public Album(Long albumId) {
        this.albumId = albumId;
    }

    public Album(Long albumId, String albumTitle, Date releaseDate, String createdBy, Date createdDate) {
        this.albumId = albumId;
        this.albumTitle = albumTitle;
        this.releaseDate = releaseDate;
        this.createdBy = createdBy;
        this.createdDate = createdDate;
    }

    public Long getAlbumId() {
        return albumId;
    }

    public void setAlbumId(Long albumId) {
        Long oldAlbumId = this.albumId;
        this.albumId = albumId;
        changeSupport.firePropertyChange("albumId", oldAlbumId, albumId);
    }

    public String getAlbumTitle() {
        return albumTitle;
    }

    public void setAlbumTitle(String albumTitle) {
        String oldAlbumTitle = this.albumTitle;
        this.albumTitle = albumTitle;
        changeSupport.firePropertyChange("albumTitle", oldAlbumTitle, albumTitle);
    }

    public Integer getDiskNumber() {
        return diskNumber;
    }

    public void setDiskNumber(Integer diskNumber) {
        Integer oldDiskNumber = this.diskNumber;
        this.diskNumber = diskNumber;
        changeSupport.firePropertyChange("diskNumber", oldDiskNumber, diskNumber);
    }

    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        Date oldReleaseDate = this.releaseDate;
        this.releaseDate = releaseDate;
        changeSupport.firePropertyChange("releaseDate", oldReleaseDate, releaseDate);
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        String oldCreatedBy = this.createdBy;
        this.createdBy = createdBy;
        changeSupport.firePropertyChange("createdBy", oldCreatedBy, createdBy);
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        Date oldCreatedDate = this.createdDate;
        this.createdDate = createdDate;
        changeSupport.firePropertyChange("createdDate", oldCreatedDate, createdDate);
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
        String oldModifiedBy = this.modifiedBy;
        this.modifiedBy = modifiedBy;
        changeSupport.firePropertyChange("modifiedBy", oldModifiedBy, modifiedBy);
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        Date oldModifiedDate = this.modifiedDate;
        this.modifiedDate = modifiedDate;
        changeSupport.firePropertyChange("modifiedDate", oldModifiedDate, modifiedDate);
    }

    @XmlTransient
    public List<Song> getSongList() {
        return songList;
    }

    public void setSongList(List<Song> songList) {
        this.songList = songList;
    }

    public Musicproductioncompany getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Musicproductioncompany companyId) {
        Musicproductioncompany oldCompanyId = this.companyId;
        this.companyId = companyId;
        changeSupport.firePropertyChange("companyId", oldCompanyId, companyId);
    }

    public Musicgroup getMusicGroupId() {
        return musicGroupId;
    }

    public void setMusicGroupId(Musicgroup musicGroupId) {
        Musicgroup oldMusicGroupId = this.musicGroupId;
        this.musicGroupId = musicGroupId;
        changeSupport.firePropertyChange("musicGroupId", oldMusicGroupId, musicGroupId);
    }

    public Artist getArtistId() {
        return artistId;
    }

    public void setArtistId(Artist artistId) {
        Artist oldArtistId = this.artistId;
        this.artistId = artistId;
        changeSupport.firePropertyChange("artistId", oldArtistId, artistId);
    }

    public Albumtype getTypeId() {
        return typeId;
    }

    public void setTypeId(Albumtype typeId) {
        Albumtype oldTypeId = this.typeId;
        this.typeId = typeId;
        changeSupport.firePropertyChange("typeId", oldTypeId, typeId);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (albumId != null ? albumId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Album)) {
            return false;
        }
        Album other = (Album) object;
        if ((this.albumId == null && other.albumId != null) || (this.albumId != null && !this.albumId.equals(other.albumId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.Album[ albumId=" + albumId + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
